<template>
  <div>
    <zbTable
      ref="tableRef"
      :api-fun="get_value_card_refund_list"
      @action="action"
    />

    <!-- 审核通过弹窗 -->
    <tongguo
      v-if="showTg"
      v-model:visible="showTg"
      :editData="editData"
      @done="done"
    />
    <!-- 审核拒绝弹窗 -->
    <reject
      v-if="showJj"
      v-model:visible="showJj"
      :editData="editData"
      @done="done"
    />
  </div>
</template>
<script setup>
  import { ref } from 'vue';
  import { message, Modal } from 'ant-design-vue';
  import { actionFn } from '@/utils/action.js';
  import { daochuFn } from '@/utils/daochu.js';
  import { PlusOutlined, UploadOutlined } from '@ant-design/icons-vue';
  import { useRouter } from 'vue-router';
  import zbTable from './components/purchasePurchaseIndex.vue';
  import tongguo from './components/tongguo.vue';
  import reject from './components/reject.vue';
  import { get_value_card_refund_list } from '@/api/order/value_card_refund';
  // 是否显示编辑弹窗
  const tableRef = ref(null);
  const router = useRouter();
  const { push } = useRouter();
  const showTg = ref(false);
  const showJj = ref(false);
  const editData = ref({});
  const actionData = ref({});

  const action = (data) => {
    console.log('data', data);
    editData.value = data.row_data;
    actionData.value.url = data.action_data.url;
    if (data.action_data.type == 'detail') {
    } else if (data.action_data.type == 'agree') {
      showTg.value = true;
    } else if (data.action_data.type == 'reject') {
      showJj.value = true;
    } else if (data.action_data.type == 'delete') {
      Modal.confirm({
        title: '提示',
        content: '确定删除，删除后不可恢复?',
        maskClosable: true,
        onOk: () => {
          done({ id: data.row_data.id });
        }
      });
    }
  };

  const done = (form) => {
    actionFn(actionData.value, form, reloadTable);
  };
  const reloadTable = () => {
    showTg.value = false;
    showJj.value = false;
    tableRef.value.reload();
  };
</script>
